<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: azim
  Date: 5/19/13
  Time: 5:29 PM
-->

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="templates/template.xhtml">

    <ui:define name="title">Podcast Add Page</ui:define>

    <ui:define name="left">

        <p:menuitem value="Add Podcast"
                    ajax="false"
                    action="#{podcastController.showAddForm}"/>
    </ui:define>

    <ui:define name="cbody">

        <p:dialog modal="true" widgetVar="statusDialog" header="Please Wail.." draggable="false"
                  closable="false" resizable="false">
            <p:graphicImage value="/resources/images/progress_bar.gif" width="250px;"/>
        </p:dialog>

        <h2>Fill Up the form below to add a podcast : </h2>
        <br/>

        <h:form id="create_podcast" enctype="multipart/form-data">

            <h:panelGrid columns="3" cellspacing="10" style="margin-bottom: 5px">

                <p:outputLabel styleClass="label" for="name" value="Name : "/>
                <p:inputText id="name"
                             value="#{podcastController.podcast.name}"
                             required="true"
                             requiredMessage="Error : Name is required"/>
                <p:message for="name" styleClass="error"/>

                <p:outputLabel styleClass="label" for="description" value="Description : "/>
                <p:inputTextarea id="description"
                                 value="#{podcastController.podcast.description}"
                                 rows="3" cols="50"
                                 required="true"
                                 requiredMessage="Error : Description is required"/>
                <p:message for="description" styleClass="error"/>

                <p:outputLabel styleClass="label" for="tags" value="Tags(comma separated) : "/>
                <p:inputText id="tags"
                             value="#{podcastController.podcast.tags}"
                             required="true"
                             requiredMessage="Error : Must enter atleast one tag."/>
                <p:message for="tags" styleClass="error"/>

                <p:outputLabel styleClass="label" for="access" value="Access : "/>
                <p:selectOneRadio id="access"
                                  value="#{podcastController.podcast.accessable}"
                                  style="padding: 5px"
                                  required="true"
                                  requiredMessage="Error : Must select an access option.">

                    <f:selectItem itemLabel="public" itemValue="true"/>
                    <p:spacer width="10"/>
                    <f:selectItem itemLabel="private" itemValue="false"/>

                </p:selectOneRadio>
                <p:message for="access" styleClass="error"/>

                <p:outputLabel styleClass="label" for="imageFile" value="Album Art : "/>
                <p:fileUpload id="imageFile"
                              value="#{podcastController.albumArt}"
                              mode="simple"
                              allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
                <p:message for="imageFile" styleClass="error"/>

                <p:outputLabel styleClass="label" for="category" value="Category : "/>
                <p:selectOneMenu id="category"
                                 value="#{podcastController.category.id}"
                                 style="padding-left: 5px; padding-right: 10px;"
                                 required="true"
                                 requiredMessage="Error : Must select a category.">

                    <f:selectItem itemLabel="Select category" itemValue=""/>
                    <c:forEach var="category" items="#{categoryController.categories}">

                        <f:selectItem itemLabel="#{category.name}" itemValue="#{category.id}"/>

                    </c:forEach>

                </p:selectOneMenu>
                <p:message for="category" styleClass="error"/>

                <p:outputLabel styleClass="label" for="audioFile" value="Audio File : "/>
                <p:fileUpload id="audioFile"
                              mode="simple"
                              value="#{podcastController.podcastFile}"
                              allowTypes="/(\.|\/)(mp3|wma)$/"/>
                <p:message for="audioFile" styleClass="error"/>

            </h:panelGrid>

            <p:commandButton value="Add Podcast"
                             ajax="false"
                             onclick="PrimeFaces.monitorDownload(start, stop)"
                             actionListener="#{podcastController.add}"/>

        </h:form>

        <p:messages globalOnly="true"/>

    </ui:define>
</ui:composition>

</html>